// import com.alibaba.druid.sql.SQLUtils;
// import com.alibaba.druid.sql.ast.SQLExpr_ptr;
// import com.alibaba.druid.sql.ast.SQLName;
// import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr;
// import com.alibaba.druid.sql.ast.expr.SQLAllColumnExpr;
// import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
// import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
// import com.alibaba.druid.sql.ast.statement.*;
// import com.alibaba.druid.util.FnvHash;
// import com.alibaba.druid.util.StringUtils;

// import java.util.*;
// import java.util.concurrent.ConcurrentHashMap;
#pragma once
#include <unordered_map>
#include "../../utils/common_ptr.h"

class Schema
{
public:
  string_ptr catalog;
  string_ptr name;
  std::unordered_map<long, SchemaObject_ptr> objects;
  std::unordered_map<long, SchemaObject_ptr> functions;
  SchemaRepository_ptr repository;

  Schema(SchemaRepository_ptr repository);

  Schema(SchemaRepository_ptr repository, string_ptr name);

  Schema(SchemaRepository_ptr repository, string_ptr catalog, string_ptr name);

  SchemaRepository_ptr getRepository();

  string_ptr getName();

  string_ptr getSimpleName();

  void setName(string_ptr name);

  SchemaObject_ptr findTable(string_ptr tableName);

  SchemaObject_ptr findTable(long nameHashCode64);

  SchemaObject_ptr findView(string_ptr viewName);

  SchemaObject_ptr findView(long nameHashCode64);

  SchemaObject_ptr findTableOrView(string_ptr tableName);

  SchemaObject_ptr findTableOrView(long hashCode64);

  SchemaObject_ptr findFunction(string_ptr functionName);

  BOOL_ptr isSequence(string_ptr name);

  SchemaObject_ptr findTable(SQLTableSource_ptr tableSource, string_ptr alias);

  SQLColumnDefinition_ptr findColumn(SQLTableSource_ptr tableSource, SQLSelectItem_ptr selectItem);

  SQLColumnDefinition_ptr findColumn(SQLTableSource_ptr tableSource, SQLExpr_ptr expr);

  SchemaObject_ptr findTable(SQLTableSource_ptr tableSource, SQLSelectItem_ptr selectItem);

  SchemaObject_ptr findTable(SQLTableSource_ptr tableSource, SQLExpr_ptr expr);

  std::unordered_map<std::string, SchemaObject_ptr> getTables(SQLTableSource_ptr x);

  void computeTables(SQLTableSource_ptr x, std::unordered_map<std::string, SchemaObject_ptr> tables);

  int getTableCount();

  SchemaObject_list_ptr getObjects();

  BOOL_ptr removeObject(long nameHashCode64);

  int getViewCount();

  string_list_ptr showTables();

  string_ptr getCatalog();
};
